#!/bin/bash
#Automated MAC Spoofing
#McFiB.sh v0.6
#By TAPE
#Last edit 26-07-2013 21:00
#Written and intended for use on Kali Linux
#Tested with success on THS-OS v3
#Intended for use on wireless nics
#
##
### FIXED SETTINGS
##################
VERS=$(sed -n 3p $0 | cut -c 11-14)	#Version information 
LED=$(sed -n 5p $0 | cut -d " " -f 3,4) #Date of last edit to script
STD=$(echo -e "\e[0;0;0m")		#Revert fonts to standard colour/format
RED=$(echo -e "\e[1;31m")		#Alter fonts to red bold
REDN=$(echo -e "\e[0;31m")		#Alter fonts to red normal
GRN=$(echo -e "\e[1;32m")		#Alter fonts to green bold
GRNN=$(echo -e "\e[0;32m")		#Alter fonts to green normal
BLU=$(echo -e "\e[1;36m")		#Alter fonts to blue bold
BLUN=$(echo -e "\e[0;36m")		#Alter fonts to blue normal
#
##
### VARIABLES
#############
CHAN=""
MENU=0
NETW=0
RAND=0
RESET=0
SCAN=15
UPDATE=0
#
##
### ROOT CHECK
##############
if [[ $UID -ne 0 ]]; then
echo "$GREEN$0$STAND should be run as root"
exit 0
fi
#
##
### EMPTY OR CREATE TEMP DIR
############################
if [ -e mcfib_temp/* ] ; then
rm mcfib_temp/*
else
mkdir mcfib_temp/
fi
#
##
### ERROR TRAP
##############
#trap f_error ERR
#
##
### CTRL-C TRAP
###############
trap f_ctrl_c INT
#
##
### EXITING SCRIPT
##################
f_exit() {
if [ -d mcfib_temp/ ] ; then rm -r mcfib_temp/ ; fi
echo $STD""
exit 0
}
#
##
### ERROR TRAP ACTION
#####################
#f_error() {
#echo $STD""
#if [ "$NETW" == "1" ] ; then f_netw ; fi
#f_exit
#exit 0
#}
#
##
### CTRL-C TRAP ACTION
######################
f_ctrl_c() {
echo $STD""
if [ "$NETW" == "1" ] ; then f_netw ; fi
f_exit
exit 0
}
#
##
### HEADER
##########
f_header() {
echo $BLU"  __  __    ___ _ ___ 
 |  \/  |__| __(_) _ )
 | |\/| / _| _|| | _ \\
 |_|  |_\__|_| |_|___/ $GRNN$VERS$STD
 Automated MAC Spoofing"
}
#
##
### VERSION INFO
################
f_version() {
clear
f_header
echo
echo " mcfib.sh $GRN$VERS$STD"
echo " By TAPE"
echo " Last edit $LED"
echo
echo -ne "View version history? y/n $GRN"
read VIEW
if [[ "$VIEW" == "Y" || "$VIEW" == "y" ]] ; then
echo $STD""
tail -n 50 $0 | sed -n "/VERSION HISTORY/,\$p"
else f_exit
fi
f_exit
}
#
##
### LISTING INTERFACES
######################
f_iface() {
airmon-ng | sed "0,/Interface/d" | cut -f 1 > mcfib_temp/iface_list.tmp
}
#
##
###LIST INTERFACES WITH MAC
###########################
f_iface_mac() {
for i in $(airmon-ng | sed "0,/Interface/d" | cut -f 1) 
do ifconfig $i | grep $i | awk '{OFS="\t"; print $1,$5}'
done
}
#
##
### NETWORK RESTART
###################
f_netw() {
echo $GRN">$STD Stopping monitor interface.."
xterm -T "McFiB -- Networking" -geometry 96x15-0+0 -e airmon-ng stop $MON
sleep 1
echo $GRN">$STD Starting networking.."
xterm -T "McFiB -- Networking" -geometry 96x15-0+0 -e /etc/init.d/networking start
sleep 1
echo $GRN">$STD Starting NetworkManager.."
xterm -T "McFiB -- Networking" -geometry 96x15-0+0 -e service network-manager start
sleep 2.5
xterm -T "McFiB -- Networking" -geometry 96x15-0+0 -e NetworkManager
}
#
#
##
### INPUT WITH MENU
###################
f_menu() {
clear
f_header
echo $BLU"   Menu based input" 
echo
echo $STD"Wireless interface(s) available;$GRN"
f_iface
f_iface_mac
echo $STD""
echo -ne $GRN">$STD Set scan interface > $GRN"
read IFACE
if [ "$IFACE" == "" ] ; then f_exit ; fi
while ! grep -Fxq $IFACE mcfib_temp/iface_list.tmp ; do
echo $RED">$STD Input error $RED[$STD$IFACE$RED]$STD interface does not exist"
echo -ne $GRN">$STD Set scan interface > $GRN"
read IFACE
done
	if [[ ! "$IFACE" =~ "mon" ]] ; then
	echo $GRN">$STD Creating monitor interface on $GRN$IFACE$STD"
	xterm -geometry 96x15-0+0 -e airmon-ng check kill
	MON=$(airmon-ng start $IFACE | grep "monitor mode enabled" | sed 's/monitor mode enabled on //' | sed 's|[^(]*(\([^)]*\)).*|\1|')	
	echo $GRN">$STD Monitor interface $GRN$MON$STD created."
	f_iface
	else MON=$IFACE	
	fi
echo -ne $GRN">$STD Set scan channel   > $GRN"
read CHAN
while [ ! `expr $CHAN + 1 2> /dev/null` ] ; do
echo $RED">$STD Input error $RED[$STD$CHAN$RED]$STD only numeric values possible"
echo -ne $GRN">$STD Set scan channel   > $GRN"
read CHAN
done
echo -ne $GRN">$STD Set scan time      > $GRN"
read SCAN
while [ ! `expr $SCAN + 1 2> /dev/null` ] && [ "$SCAN" != "" ] ; do
echo $RED">$STD Input error $RED[$STD$SCAN$RED]$STD only numeric values possible"
echo -ne $GRN">$STD Set scan time      > $GRN"
read SCAN
done
if [ "$SCAN" == "" ] ; then SCAN=15 ; fi
echo -e $GRN">$STD Starting airodump-ng"
	if [ "$CHAN" == "" ] ; then
	timeout -k 30s $SCAN xterm -T "McFiB -- airodump-ng" -geometry 96x36-0+0 -e airodump-ng mon0 -a -f 1000 --output-format csv -w mcfib_temp/temp
	else 
	timeout -k 30s $SCAN xterm -T "McFiB -- airodump-ng" -geometry 96x36-0+0 -e airodump-ng mon0 -a -c $CHAN --output-format csv -w mcfib_temp/temp
	fi
cat mcfib_temp/temp-01.csv | sed '0,/BSSID/d;/Station MAC/,$d' | awk -F , '{print $1, $14}' > mcfib_temp/AP_list.tmp
cat mcfib_temp/temp-01.csv | sed '0,/Station MAC/d' | sed '/(not associated)/d' | awk -F , '{print $1,$6}' > mcfib_temp/CL_list.tmp
awk 'NR==FNR {A[$1]=$2; next} {print $2,$1,A[$2]}' mcfib_temp/AP_list.tmp mcfib_temp/CL_list.tmp > mcfib_temp/assoc_list.tmp
#Check size of file to evaluate if contents or not. <-- HALP ! needs to be bettah..
CONT=$(du -b mcfib_temp/CL_list.tmp | cut -f 1)
if (( "$CONT" < 10)) ; then
echo
echo $RED">$STD No associated clients found.."
if [[ ! "$IFACE" =~ "mon" ]] ; then
echo -ne $GRN">$STD Stop monitor interface and reset networking ? y/n $GRN"
read NETW
	if [[ "$NETW" == "y" || "$NETW" == "Y" ]] ; then
	f_netw
	else
	f_exit
	fi
fi 
f_exit
fi
echo
echo -e $RED"##\tAP BSSID\t\tASSOCIATED CLIENT\tESSID" > mcfib_temp/assoc_list1.tmp
echo -e $BLU"--\t-----------------\t-----------------\t-----"$STD >> mcfib_temp/assoc_list1.tmp
cat mcfib_temp/assoc_list.tmp | sed '/./=' | sed '/./N;s/\n/ /' | sed 's/ /\t/g' | sed '$d' >> mcfib_temp/assoc_list1.tmp
cat mcfib_temp/assoc_list1.tmp
FIRST=$(cat mcfib_temp/assoc_list1.tmp | sed -n '3p' | awk '{print $1}')
LAST=$(cat mcfib_temp/assoc_list1.tmp | sed -n '$p' | awk '{print $1}')
echo
echo -ne $GRN">$STD Select # from list to spoof client MAC > $GRN"
read SMAC
while [[ "$SMAC" != [$FIRST-$LAST] ]] ; do
echo $RED">$STD Input error $RED[$STD$SMAC$RED]$STD list entry does not exist"
echo -ne $GRN">$STD Select # from list to spoof client MAC > $GRN"
read SMAC
done
echo -ne $GRN">$STD Set interface to spoof  > $GRN"
read SIFACE
if [ "$SIFACE" == "" ] ; then f_exit ; fi
while ! grep -Fxq $SIFACE mcfib_temp/iface_list.tmp ; do
echo $RED">$STD Input error $RED[$STD$SIFACE$RED]$STD interface does not exist"
echo -ne $GRN">$STD Set interface to spoof  > $GRN"
read SIFACE
done
echo $STD""
SMAC=$(expr $SMAC + 2)
SMAC=$(sed -n "$SMAC p" mcfib_temp/assoc_list1.tmp | awk '{print $3}')
ifconfig $SIFACE down
xterm -geometry 96x24-0+0 -e macchanger -m $SMAC $SIFACE
ifconfig $SIFACE up
echo $STD"Interface $GRN$SIFACE$STD now has MAC $GRN$SMAC$STD"
if [[ ! "$IFACE" =~ "mon" ]] ; then
echo -ne $GRN">$STD Stop monitor interface and reset networking ? y/n "
read NETW
	if [[ "$NETW" == "y" || "$NETW" == "Y" ]] ; then
	f_netw
	else
	f_exit
	fi
fi
f_exit
}
#
##
### SET SPECIFIC MAC
####################
f_macch() {
if [ -z $SIFACE ] ; then
echo $RED">$STD Spoof interface error $RED[$STD-I$RED]$STD no interface specified"
echo $STD"Wireless interface(s) available;"$GRN
f_iface_mac
f_exit
	elif ! grep -Fxq $SIFACE mcfib_temp/iface_list.tmp ; then
	echo $RED">$STD Spoof interface error $RED[$STD-I $SIFACE$RED]$STD interface does not exist"
	echo "Wireless interface(s) available;"$GRN
	f_iface_mac
	f_exit
	elif [ "$SIFACE" == "" ] ; then 
	echo $RED">$STD Spoof interface error $RED[$STD-I$RED]$STD no interface specified"
	echo "Wireless interface(s) available;"$GRN
	f_iface_mac 
	f_exit
fi
#Allow spacing of digits with dash (-) instead of colon (:)
if [[ "$MACCH" =~ ^[0-9a-fA-F]{2}-[0-9a-fA-F]{2}-[0-9a-fA-F]{2}-[0-9a-fA-F]{2}-[0-9a-fA-F]{2}-[0-9a-fA-F]{2}$ ]] ; then
MACCH=$(echo "$MACCH" | sed 's/-/:/g')
echo $BLU"> $STD Function to set specified MAC on $GRN$SIFACE$STD"
sleep 1
echo $GRN"> $STD Putting interface $GRN$SIFACE$STD down.."
ifconfig $SIFACE down
echo $GRN"> $STD Running macchanger with setting -m"
macchanger -m $MACCH $SIFACE
echo $GRN"> $STD Putting interface $GRN$SIFACE$STD up.."
ifconfig $SIFACE up
f_exit
#With spacing of usual colon (:)
elif [[ "$MACCH" =~ ^[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}$ ]] ; then
echo $BLU"> $STD Function to set specified MAC on $GRN$SIFACE$STD"
sleep 1
echo $GRN"> $STD Putting interface $GRN$SIFACE$STD down.."
ifconfig $SIFACE down
echo $GRN"> $STD Running macchanger with setting -m"
macchanger -m $MACCH $SIFACE
echo $GRN"> $STD Putting interface $GRN$SIFACE$STD up.."
ifconfig $SIFACE up
f_exit
else
echo $RED">$STD Input error $RED[$STD-f $MACCH$RED]$STD Incorrect MAC syntax."
f_exit
fi
}
#
##
### RANDOMIZE MAC
#################
f_rand() {
if [ -z $SIFACE ] ; then
echo $RED">$STD Spoof interface error $RED[$STD-I$RED]$STD no interface specified"
echo $STD"Wireless interface(s) available;"$GRN
f_iface_mac
f_exit
	elif ! grep -Fxq $SIFACE mcfib_temp/iface_list.tmp ; then
	echo $RED">$STD Spoof interface error $RED[$STD-I $SIFACE$RED]$STD interface does not exist"
	echo "Wireless interface(s) available;"$GRN
	f_iface_mac
	f_exit
fi
echo $BLU"> $STD Function to set random MAC on $GRN$SIFACE$STD"
sleep 1
echo $GRN"> $STD Putting interface $GRN$SIFACE$STD down.."
ifconfig $SIFACE down
echo $GRN"> $STD Running macchanger with setting -A"
macchanger -A $SIFACE
echo $GRN"> $STD Putting interface $GRN$SIFACE$STD up.."
ifconfig $SIFACE up
f_exit
}
#
##
### RESET MAC
#############
f_reset() {
if [ -z $SIFACE ] ; then
echo $RED">$STD Spoof interface error $RED[$STD-I$RED]$STD no interface specified"
echo $STD"Wireless interface(s) available;"$GRN
f_iface_mac
f_exit
	elif ! grep -Fxq $SIFACE mcfib_temp/iface_list.tmp ; then
	echo $RED">$STD Spoof interface error $RED[$STD-I $SIFACE$RED]$STD interface does not exist"
	echo "Wireless interface(s) available;"$GRN
	f_iface_mac
	f_exit
fi
echo $BLU"> $STD Function to reset original MAC of $GRN$SIFACE$STD"
sleep 1
echo $GRN"> $STD Putting interface $GRN$SIFACE$STD down.."
ifconfig $SIFACE down
echo $GRN"> $STD Resetting the permanent MAC of interface $GRN$SIFACE$STD"
macchanger -p $SIFACE
echo $GRN"> $STD Putting interface $GRN$SIFACE$STD up.."
ifconfig $SIFACE up
f_exit
}
#
##
### UPDATE
##########
f_update() {
clear
f_header
echo
echo $BLU">$STD Update function"
echo $STD""
echo -ne $STD"Check the latest version available ? y/n "$GRN
read UPD
echo $STD""
LOC=$(pwd)
if [[ $UPD == "y" || $UPD == "Y" ]] ; then 
echo $GRN">$STD Checking Internet connection.."
wget -q --tries=10 --timeout=5 http://www.google.com -O /tmp/index.google &> /dev/null
	if [ ! -s /tmp/index.google ];then
	echo $RED">$STD No internet connection found..$STD"
	sleep 1
	f_exit
	fi
echo $GRN">$STD Getting info on latest available version.."
NEW_VERS=$(curl -s http://mcfib.googlecode.com/svn/mcfib.sh | sed -n 3p | cut -c 11-14)
NEW_LED=$(curl -s http://mcfib.googlecode.com/svn/mcfib.sh | sed -n 5p | cut -d " " -f 3)
echo $GRN">$STD Checking if latest version in use.."
if [ "$VERS" != "$NEW_VERS" ] ; then
echo $RED">$STD Version in use is $RED$VERS$STD last edited on $LED"
echo $GRN">$STD Latest version is $GRN$NEW_VERS$STD last edited on $NEW_LED"
echo -n $GRN">$STD Update to latest ? y/n "$GRN
read UPD1
	if [[ "$UPD1" == "y" || "$UPD1" == "Y" ]] ; then 
		echo $GRN">$STD Downloading latest version.."
		wget -q http://mcfib.googlecode.com/svn/mcfib.sh -O $LOC/mcfib.tmp
		#if [ -d /opt/backbox ] ; then 
		#sudo cp $LOC/mcfib.tmp /opt/mcfib/mcfib.sh
		#sudo cp $LOC/mcfib.tmp /usr/bin/mcfib.sh
		#echo $GRN">$STD Please restart$GRN mcfib.sh$STD"
		#rm $LOC/mcfib.tmp 
		#f_exit 
		#fi
		chmod +x $LOC/mcfib.tmp
		mv $LOC/mcfib.tmp $LOC/mcfib.sh
		echo $STD""
		echo $GRN">$STD Latest mcfib.sh version has been saved to $GRN$LOC/mcfib.sh$STD"
		#tail -n 30 $LOC/mcfib.sh | sed -n "/$VERS/,\$p"
		echo $GRN">$STD Please restart$GRN mcfib.sh$STD"
		f_exit
		else
		f_exit
		fi
	elif [ "$VERS" == "$NEW_VERS" ] ; then
	echo $GRN">$STD Current version in use $GRN$VERS$STD is the latest version available."
	sleep 1
	f_exit
	fi
else		
f_exit
fi
}
#
##
### HELP INFO
#############
f_help() {
clear
f_header
echo $STD"
SCAN OPTIONS
-c --- Channel on which to scan for associated clients
       (default set to all channels with hop interval of 1 sec)
-i --- Interface to scan for associated clients
-I --- Interface to spoof MAC on
-m --- Menu based input
       (Use without any other switches)
-n --- Networking reset after scanning and spoofing
-s --- Scantime duration in seconds
       (default set to 15)

MAC ADDRESS MANIPULATION OPTIONS
(Use together with -I <interface>)
-f --- Set fixed specific MAC on interface
-r --- Set random MAC on interface
-R --- Reset interface MAC to original permanent MAC

MISCELLANEOUS OPTIONS
(Use without any other switches)
-h --- This help information
-u --- Update check
-v --- Version & Version history

EXAMPLES
./mcfib.sh -m
./mcfib.sh -I wlan0 -f 00:11:22:33:44:55
./mcfib.sh -I wlan0 -r
./mcfib.sh -I wlan0 -R
./mcfib.sh -i mon0 -I wlan0
./mcfib.sh -i wlan0 -I wlan0 -c 1 -s 60
./mcfib.sh -i mon0 -I wlan0 -c 11 -s 60 -n
./mcfib.sh -u"
f_exit
}
#
##
### OPTION FUNCTIONS
####################
while getopts ":c:f:i:I:s:vhmnNrRu" opt; do
  case $opt in
	c)
	CHAN=$OPTARG ;;
	f)
	MACCH=$OPTARG ;;	
	h) 
	f_help ;;
	i) 
	IFACE=$OPTARG ;;
	I)
	SIFACE=$OPTARG ;;
	m)
	MENU=1 ;;
	n)
	NETW=1 ;;
	N)
	read RED REDN GRN GRNN BLU BLUN <<< $(echo -e "\e[0;0;0m")
	;;
	r)
	RAND=1 ;;
	R)
	RESET=1 ;;
	s)
	SCAN=$OPTARG ;;
	u)
	UPDATE=1 ;;
	v)
	f_version ;;
	*) echo $RED">$STD Input error. For help & examples: $GRN./mcfib.sh -h$STD" ; f_exit
  esac
done
#
##
### INPUT CHECKS
################
#If no input print header & help
if [ $# -eq 0 ] ; then 
f_header
echo "
GENERAL USAGE:
./mcfib.sh -i <scan_iface> -I <spoof_iface> [-c channel] [-s scantime]

For help & examples: $GRN./mcfib.sh -h$STD"
f_exit
fi
#If -m set, run menu script
if [ "$MENU" == "1" ] ; then f_menu
else f_iface
fi
#If -r set, run mac randomizer function 
if [ "$RAND" == "1" ] ; then f_rand ; fi
#If -R set, run reset function
if [ "$RESET" == "1" ] ; then f_reset ; fi
#If -f set, run fixed specific mac changer function
if [ -n "$MACCH" ] ; then f_macch ; fi
#If -u set, run update function
if [ "$UPDATE" == "1" ] ; then f_update ; fi
#If no scan iface set, list available ifaces 
if [ -z $IFACE ] ; then 
echo $RED">$STD Scan interface error $RED[$STD-i$RED]$STD must enter scan interface"
echo "Wireless interface(s) available;"$GRN
f_iface_mac
f_exit
	elif ! grep -Fxq $IFACE mcfib_temp/iface_list.tmp ; then
	echo $RED">$STD Scan interface error $RED[$STD-i $IFACE$RED]$STD interface does not exist"
	echo "Wireless interface(s) available;"$GRN
	f_iface_mac
	f_exit
fi
#If no Spoof iface set, list available ifaces
if [ -z $SIFACE ] ; then
echo $RED">$STD Spoof interface error $RED[$STD-I$RED]$STD must enter interface to spoof"
echo "Wireless interface(s) available;"$GRN
f_iface_mac
f_exit
	elif ! grep -Fxq $SIFACE mcfib_temp/iface_list.tmp ; then
	echo $RED">$STD Spoof interface error $RED[$STD-I $SIFACE$RED]$STD interface does not exist"
	echo "Wireless interface(s) available;"$GRN
	f_iface_mac
	f_exit
fi
#If set channels not numeric, error
if [ -n $CHAN ] && [ ! `expr $CHAN + 1 2> /dev/null` ] ; then
echo $RED">$STD Channel input error $RED[$STD-c $CHAN$RED]$STD only numeric values possible"
echo "-h for help"
f_exit
#If set scantime not numeric, error
elif [ -n $SCAN ] && [ ! `expr $SCAN + 1 2> /dev/null` ] ; then
echo $RED">$STDScantime input error $RED[$STD-s $SCAN$RED]$STD only numeric values possible"
echo "-h for help"
f_exit
fi
#
##
### RUNNING SCRIPT
##################
#If not a mon iface, start iface and create mon iface
if [[ ! "$IFACE" =~ "mon" ]] ; then
echo $GRN">$STD Creating monitor interface on $GRN$IFACE$STD.."
xterm -geometry 96x15-0+0 -e airmon-ng check kill
MON=$(airmon-ng start $IFACE | grep "monitor mode enabled" | sed 's/monitor mode enabled on //' | sed 's|[^(]*(\([^)]*\)).*|\1|')
echo $GRN">$STD Monitor interface $GRN$MON$STD created.."
else MON=$IFACE	
fi
#airodump start and writing to csv
echo $GRN">$STD Starting airodump-ng.."
	if [ "$CHAN" == "" ] ; then
	timeout -k 30s $SCAN xterm -T "McFiB -- airodump-ng" -geometry 96x36-0+0 -e airodump-ng $MON -a -f 1000 --output-format csv -w mcfib_temp/temp
	else 
	timeout -k 30s $SCAN xterm -T "McFiB -- airodump-ng" -geometry 96x36-0+0 -e airodump-ng $MON -a -c $CHAN --output-format csv -w mcfib_temp/temp
	fi
#Creating lists of APs, AssociatedClients and Essids
cat mcfib_temp/temp-01.csv | sed '0,/BSSID/d;/Station MAC/,$d' | awk -F , '{print $1, $14}' > mcfib_temp/AP_list.tmp
cat mcfib_temp/temp-01.csv | sed '0,/Station MAC/d' | sed '/(not associated)/d' | awk -F , '{print $1,$6}' > mcfib_temp/CL_list.tmp
awk 'NR==FNR {A[$1]=$2; next} {print $2,$1,A[$2]}' mcfib_temp/AP_list.tmp mcfib_temp/CL_list.tmp > mcfib_temp/assoc_list.tmp
#Checking size of files to evaluate content or not !! <-- HALP ! Needs to do it bettah..
CONT=$(du -b mcfib_temp/CL_list.tmp | cut -f 1)
if (( "$CONT" < 10)) ; then
echo $RED">$STD No associated clients found.."
if [ "$NETW" == "1" ] ; then f_netw ; fi
f_exit
fi
#Printing and formatting the lists 
echo $GRN">$STD Listing found associated clients.."
echo -e "##\tAP BSSID\t\tASSOCIATED CLIENT\tESSID" > mcfib_temp/assoc_list1.tmp
echo -e "--\t-----------------\t-----------------\t-----"$STD >> mcfib_temp/assoc_list1.tmp
cat mcfib_temp/assoc_list.tmp | sed '/./=' | sed '/./N;s/\n/ /' | sed 's/ /\t/g' | sed '$d' >> mcfib_temp/assoc_list1.tmp
cat mcfib_temp/assoc_list1.tmp
#Test for correct choice input from list
FIRST=$(cat mcfib_temp/assoc_list1.tmp | sed -n '3p' | awk '{print $1}')
LAST=$(cat mcfib_temp/assoc_list1.tmp | sed -n '$p' | awk '{print $1}')
echo
echo -ne $GRN">$STD Select # from list to spoof client MAC > $GRN"
read LISTNR
while [[ "$LISTNR" != [$FIRST-$LAST] ]] ; do
echo $RED">$STD Input error $RED[$STD$LISTNR$RED]$STD list entry does not exist	"
echo -ne $GRN">$STD Select # from list to spoof client MAC > $GRN"
read LISTNR
done
#Selecting correct Client and spoofing with macchanger
echo $GRN">$STD Spoofing MAC of interface $GRN$SIFACE$STD.."
LISTNR=$(expr $LISTNR + 2)
SMAC=$(sed -n "$LISTNR p" mcfib_temp/assoc_list1.tmp | awk '{print $3}')
SAP=$(sed -n "$LISTNR p" mcfib_temp/assoc_list1.tmp | awk '{print $2}')
ifconfig $SIFACE down
xterm -geometry 96x24-0+0 -e macchanger -m $SMAC $SIFACE
ifconfig $SIFACE up 
echo $GRN">$STD Interface $GRN$SIFACE$STD now has MAC $GRN$SMAC$STD"
#Network information from where client MAC was spoofed. 
ESSID=$(cat mcfib_temp/temp-01.csv | sed '0,/BSSID/d;/Station MAC/,$d' | grep $SAP | cut -d , -f 14 | sed 's/[ ]//')
SCHAN=$(cat mcfib_temp/temp-01.csv | sed '0,/BSSID/d;/Station MAC/,$d' | grep $SAP | cut -d , -f 4 | sed -e 's/^ *//' -e 's/ *$//')
ENC=$(cat mcfib_temp/temp-01.csv | sed '0,/BSSID/d;/Station MAC/,$d' | grep $SAP | cut -d , -f 6 | sed -e 's/^ *//' -e 's/ *$//')
CIPH=$(cat mcfib_temp/temp-01.csv | sed '0,/BSSID/d;/Station MAC/,$d' | grep $SAP | cut -d , -f 7 | sed -e 's/^ *//' -e 's/ *$//')
AUTH=$(cat mcfib_temp/temp-01.csv | sed '0,/BSSID/d;/Station MAC/,$d' | grep $SAP | cut -d , -f 8 | sed -e 's/^ *//' -e 's/ *$//')
echo $STD"#$BLUN ------------------------------------- $STD#"
echo $STD"#$BLUN Network details of spoofed client MAC $STD#
$BLUN|$STD SSID-------> $GRNN$ESSID$STD 
$BLUN|$STD BSSID------> $GRNN$SAP$STD
$BLUN|$STD CHANNEL----> $GRNN$SCHAN$STD
$BLUN|$STD CLIENT MAC-> $GRNN$SMAC$STD
$BLUN|$STD ENCRYPTION-> $GRNN$ENC$STD
$BLUN|$STD CIPHER-----> $GRNN$CIPH$STD
$BLUN|$STD AUTH-------> $GRNN$AUTH$STD
#$BLUN ------------------------------------- $STD#"

if [ "$NETW" == "1" ] ; then f_netw ; fi

f_exit

#The End 
#
##
### VERSION HISTORY
###################
#
##Version 0.1a -- released 11-07-2013 on THS Forums
#
##Version 0.2 -- released 12-07-2013
#- Putting interface back up after spoofing with -r switch fixed.
#- Edited wording to make it more clear the interfaces are wireless when showing interfaces.
#- Updated help info to correct EXAMPLES syntax (Thanks TH3CR@CK3R).
#
##Version 0.3 -- released 15-07-2013
#- Changed name of temp directory to 'mcfib_temp'.
#- Included possibility to change MAC of created mon interface when using menu (Thanks TH3CR@CK3R).
#
##Version 0.4 -- released 18-07-2013
#- Included an option (-R) to reset the MAC to the interface's original MAC (Thanks OE 800).
#- Made error notices more uniform.
#
##Version 0.5 -- released 26-07-2013
#- Created google code page for mcfib for updates.
#- Included an update function (-u).
#- Incuded information on the network the Client MAC was spoofed from (does not appear when running Menu based input)
#- Some tweaks to the listing and parsing of information.
#- Tweaked the listing of network information to avoid leading/trailing spaces except on ESSIDs.
#- Altered menu based input switch to -M.
#- Included function to set specific mac (-m).
#- Included the MAC addresses when listing available interfaces.
#
##Version 0.6 -- released 26-07-2013
#- Altered the fixed MAC setting to -f so as to not interfere with fixed settings in THS-OS v3.
#- Reverted the menu based input switch from -M back to -m.
#
#
#To do;
#======
#> Improve error reporting.
#> Improve and optimize coding.
#> Continue efforts on automated connections to selected networks.
#> Get some feedback :D
#> Continue to make it better ;)